package com.itheima;

import com.itheima.config.SpringConfig;
import com.itheima.domain.Account;
import com.itheima.service.AccountService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @author 92609
 * TODO：spring整合mybatis
 *
 *  1.少了mybatis核心配置类和mybatis工具类
 *  2.AccountServiceImpl 在调用dao层时已经符合了ioc思想
 *
 *  3.多了什么
 *      1）包spring-jdbc 和 mybatis-spring
 *      2）SpringConfig多了
 *          i）导入MyBatisConfig
 *          ii）加载配置文件jdbc.properties
 *          iii）连接池
 *      3）多了MyBatisConfig
 *          i）pojo的别名包扫描
 *          ii）接口包扫描
 *          iii）对象的ioc管理    将dao层接口实现类注册到ioc容器中
 */
public class App {
    public static void main(String[] args) {
        ApplicationContext ctx = new AnnotationConfigApplicationContext(SpringConfig.class);
        AccountService accountService = ctx.getBean(AccountService.class);
//        AccountService accountService = (AccountService) ctx.getBean("accountService");
        Account ac = accountService.findById(1);
        System.out.println(ac);
    }
}
